<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>清除定时器</title>
</head>
<body>
<!--要求从0 开始，每秒加1，到9 停止-->
<div id="clock"></div>

<script>
    let element = document.getElementById("clock");

    let time = 0;


    let timer = setInterval(function () {
        time++
        element.innerText = time
    }, 1000)

    setTimeout(function () {
        // console.log("abc");
        clearInterval(timer)
        element.innerText = 0
    }, 10000)

    // clearInterval(timer)
</script>
</body>
</html>